package util;

import static util.Dictionary.CODE.SUCCESS;

public class JsonRsp {
    private int code;
    private String msg;
    private Object data;
    private long count;


    private JsonRsp(){}

    private JsonRsp(Object data, int code, String msg){
        this.code = code;
        this.data = data;
        this.msg=msg;
    }
    public static JsonRsp success(Object data){
        return new JsonRsp(data,0,null);
    }
    public static JsonRsp success(Object data, String msg){
        return new JsonRsp(data,0,msg);
    }
    public static JsonRsp fail(int code, String msg, Object data){return new JsonRsp(data,code,msg);}
    public static JsonRsp fail(int code, String msg){
        return new JsonRsp(null, code, msg);
    }
    public static JsonRsp fail(int code){
        return new JsonRsp(null,code, null);
    }
    public JsonRsp setCount(long count){
        this.count = count;
        return this;
    }
    public long getCount() {
        return count;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

//    public Object getData() {
//        return cols;
//    }


    public Object getData() {
        return data;
    }
}
